package com.example.parallelTemplate.commons.task;

import com.example.parallelTemplate.commons.dto.BaseRspDTO;
import com.example.parallelTemplate.commons.dto.UserInfoDTO;
import com.example.parallelTemplate.commons.param.UserInfoParam;
import com.example.parallelTemplate.commons.req.AppInfoReq;
import com.example.parallelTemplate.commons.service.IUserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 用户信息策略类
 */
@Service
public class UserInfoStrategyTask implements IBaseTask {

    @Resource
    private IUserService userService;

    @Override
    public String getTaskType() {
        return "userInfoDTO";
    }

    @Override
    public BaseRspDTO<Object> execute(AppInfoReq req) {
        UserInfoParam userInfoParam = userService.buildUserParam(req);
        UserInfoDTO userInfoDTO = userService.queryUserInfo(userInfoParam);
        BaseRspDTO<Object> userBaseRspDTO = new BaseRspDTO<Object>();
        userBaseRspDTO.setKey(getTaskType());
        userBaseRspDTO.setData(userInfoDTO);
        return userBaseRspDTO;
    }
}
